package com.theo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.theo.entity.StockInfo;
import com.theo.mapper.StockInfoMapper;
import com.theo.service.StockInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.catalina.StoreManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 方涛
 * @since 2021-02-02
 */
@Service
public class StockInfoServiceImpl extends ServiceImpl<StockInfoMapper, StockInfo> implements StockInfoService {
    @Autowired
    private StockInfoMapper stockInfoMapper;

    @Override
    public int saveStockInfo(StockInfo stockInfo) {
        return stockInfoMapper.insert(stockInfo);
    }

    @Override
    public int deleteStockInfo(Integer id) {
        return stockInfoMapper.deleteById(id);
    }

    @Override
    public int updateSotckInfo(StockInfo stockInfo) {
        return stockInfoMapper.updateById(stockInfo);
    }

    @Override
    public List<StockInfo> queryAllStockInfo() {
        return stockInfoMapper.queryAllStockInfo();
    }

    @Override
    public StockInfo queryStockInfoById(Integer id) {
        return stockInfoMapper.selectById(id);
    }

    @Override
    public List<StockInfo> queryStockInfoByHospitalId(Integer id) {
        return stockInfoMapper.queryStockInfoByHospitalId(id);
    }

    @Override
    public StockInfo queryStockInfoByArticleId(Integer id) {
        QueryWrapper<StockInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("article_id", id);
        return stockInfoMapper.selectOne(wrapper);
    }
}
